package com.itheima.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingltonldbcTemplate {
    private static JdbcTemplate jdbcTemplate=null;
    public static JdbcTemplate getJdbcTemplate(){
        if (jdbcTemplate == null){
            DruidDataSource druidDataSource = new DruidDataSource();
            druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
            druidDataSource.setUrl("jdbc:mysql://localhost:3306/test");
            druidDataSource.setUsername("root");
            druidDataSource.setPassword("root");

            jdbcTemplate = new JdbcTemplate();
            jdbcTemplate.setDataSource(druidDataSource);
        }
        return jdbcTemplate;
    }
}
